package com.mc.web.controller.fil;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mc.common.annotation.Log;
import com.mc.common.core.controller.BaseController;
import com.mc.common.core.domain.AjaxResult;
import com.mc.common.enums.BusinessType;
import com.mc.fil.domain.FilSow;
import com.mc.fil.service.IFilSowService;
import com.mc.common.utils.poi.ExcelUtil;
import com.mc.common.core.page.TableDataInfo;

/**
 * 播种信息 Controller
 *
 * @author mc
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/fil/sow")
public class FilSowController extends BaseController
{
    @Autowired
    private IFilSowService filSowService;

    /**
     * 查询播种信息 列表
     */
    @PreAuthorize("@ss.hasPermi('fil:sow:list')")
    @GetMapping("/list")
    public TableDataInfo list(FilSow filSow)
    {
        startPage();
        List<FilSow> list = filSowService.selectFilSowList(filSow);
        return getDataTable(list);
    }

    /**
     * 导出播种信息 列表
     */
    @PreAuthorize("@ss.hasPermi('fil:sow:export')")
    @Log(title = "播种信息 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FilSow filSow)
    {
        List<FilSow> list = filSowService.selectFilSowList(filSow);
        ExcelUtil<FilSow> util = new ExcelUtil<FilSow>(FilSow.class);
        return util.exportExcel(list, "sow");
    }

    /**
     * 获取播种信息 详细信息
     */
    @PreAuthorize("@ss.hasPermi('fil:sow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(filSowService.selectFilSowById(id));
    }

    /**
     * 新增播种信息
     */
    @PreAuthorize("@ss.hasPermi('fil:sow:add')")
    @Log(title = "播种信息 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FilSow filSow)
    {
        return toAjax(filSowService.insertFilSow(filSow));
    }

}